<?php

namespace app\api\validate;

use think\Validate;

class Student extends Validate
{
    /**
     * 验证规则
     * @var array
     */
    protected $rule = [
        'id|学生编号' => 'require',
        'name|学生姓名' => 'require|min:3|max:15',
        'sex|学生性别' => 'require|in:男,女',
        'birth|学生生日' => 'require|date',
        'department|学生系别' => 'require',
        'address|学生地址' => 'require',
    ];

    /**
     * 验证场景
     * @var array
     */
    protected $scene = [
        'add' => ['name', 'sex', 'birth', 'department', 'address'],
        'update' => ['id', 'name', 'sex', 'birth', 'department', 'address'],
        'delete' => ['id'],
        'getById' => ['id'],
    ];

    /**
     * 验证提示
     * @var string[]
     */
    protected $message = [
        'id.require' => '请输入学生编号',
        'name.require' => '请输入学生姓名',
        'name.min' => '学生姓名长度不能小于3',
        'name.max' => '学生姓名长度不能大于15',
        'sex.require' => '请输入学生性别',
        'sex.in' => '学生性别只能为男或女',
        'birth.require' => '请输入学生生日',
        'birth.date' => '学生生日格式不正确',
        'department.require' => '请输入学生系别',
        'address.require' => '请输入学生地址',
    ];
}